<template>
  <div style="background:#FF4C50;color:#ffffff;width:100vw;height:60px;line-height:60px;padding: 0px 4vw;" >
        <span style="font-size:28px;">限量购</span>
        <span style="float:right">倒计时：{{timeLimit.day}}天{{timeLimit.hour}}时{{timeLimit.min}}分{{timeLimit.sec}}秒</span>
  </div>
</template>
<script>
export default {
    name:'timeLimit',
    components:{
        
    },
    data () {
        return {
            dayEnd:'2018-10-05 10:00:00',
            timeLimit:{
                day:null,
                hour:null,
                min:null,
                sec:null,
            },
            
            dateNow:'',
        }
    },
    computed:{
        settimer:function(){
            var that=this
            setInterval(function(){
                var dateEnd=new Date(that.dayEnd);
                that.dateNow=new Date();
                var surplusTime= dateEnd.getTime()-that.dateNow.getTime();
                that.timeLimit.day=Math.floor(surplusTime/1000/24/3600);
                that.timeLimit.hour=Math.floor((surplusTime-that.timeLimit.day*1000*24*3600)/1000/3600);
                that.timeLimit.min=Math.floor((surplusTime-that.timeLimit.day*1000*24*3600-that.timeLimit.hour*1000*3600)/1000/60);
                that.timeLimit.sec=Math.floor((surplusTime-that.timeLimit.day*1000*24*3600-that.timeLimit.hour*1000*3600-that.timeLimit.min*1000*60)/1000);
            },200)
        }
    },
    methods:{
        
    },
    created() {
        var dateEnd=new Date(this.dayEnd);
        this.dateNow=new Date();
        var surplusTime= dateEnd.getTime()-this.dateNow.getTime();
        this.timeLimit.day=Math.floor(surplusTime/1000/24/3600);
        this.timeLimit.hour=Math.floor((surplusTime-this.timeLimit.day*1000*24*3600)/1000/3600);
        this.timeLimit.min=Math.floor((surplusTime-this.timeLimit.day*1000*24*3600-this.timeLimit.hour*1000*3600)/1000/60);
        this.timeLimit.sec=Math.floor((surplusTime-this.timeLimit.day*1000*24*3600-this.timeLimit.hour*1000*3600-this.timeLimit.min*1000*60)/1000);
    },
    mounted() {
        this.settimer()
    },

    
}
</script>
<style lang='scss'>

</style>